const koa = require('koa2');
const app = new koa();
// const router = require('koa-router')();
let path = require('path');
const glob = require('glob');

/*
class Router {
    private route;

    constructor (r) {
        this.route = r;
    }

    public get(patt, call)
    {
        this.route.get(patt, async (ctx, next) => {
            ctx.body = await call(ctx, next);
        });
    }

    public post(patt, call)
    {
        this.route.post(patt, async (ctx, next) => {
            ctx.body = await call(ctx, next);
        });
    }

    public delete(patt, call)
    {
        this.route.delete(patt, async (ctx, next) => {
            ctx.body = await call(ctx, next);
        });
    }

    public put(patt, call)
    {
        this.route.put(patt, async (ctx, next) => {
            ctx.body = await call(ctx, next);
        });
    }
}
const files = glob.sync('./routes/*.ts');
files.forEach((file) => {
    require(file)(new Router(router));
})

app.use(router.routes());
app.use(router.allowedMethods());
*/

type Request = {
    module: string;
    controller: string;
    action: string;
}
let router = new (require('./src/lib/Router.ts'))(app);
router.register('get', '/', 'index/index/index');
router.register('get', '/user', 'index/user');


app.listen(3000, () => {
    console.log('starting at http://localhost:3000/')
});

